package cn.com.hhrcw.service.impl;

import cn.com.hhrcw.entity.SysLog;
import cn.com.hhrcw.mapper.MySysLogMapper;
import cn.com.hhrcw.service.ISysLogService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * <p>
    * 系统日志表 服务实现类
    * </p>
 *
 * @author jiangdong
 * @since 2020-11-30
 */
@Service
@Transactional(rollbackFor = Exception.class)
public class MySysLogServiceImpl extends ServiceImpl<MySysLogMapper, SysLog> implements ISysLogService {

    @Autowired
    private JdbcTemplate jdbcTemplate;

    @Override
    public List<SysLog> sevenData() {
        return jdbcTemplate.query("select * from sys_log where DATE_SUB(CURDATE(), INTERVAL 6 DAY) <= date(create_time)  " +
            "and log_type = 1 and userid is not null and log_content like '%个人用户%' ORDER BY create_time ", new BeanPropertyRowMapper<>(SysLog.class));
    }
}
